<!--
 * @Descripttion: 预约客户
 * @Author: xiao li
 * @Date: 2020-07-06 12:17:07
 * @LastEditors: xiao li
 * @LastEditTime: 2021-04-29 13:50:43
-->
<template>
    <div class="lb-app-house-customer">
        <top-nav></top-nav>
        <div class="page-main">
            <el-table
            v-loading='loading'
            :data="tableData"
          :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
            style="width: 100%">
                <el-table-column
                    prop="id"
                    label="ID">
                </el-table-column>
                <el-table-column
                    label="头像">
                    <template slot-scope="scope">
                        <lb-image  :src="scope.row.avatar" />
                    </template>
                </el-table-column>
                <el-table-column
                    prop="contact"
                    label="联系人">
                </el-table-column>
                <el-table-column
                    prop="tel"
                    label="预约电话">
                </el-table-column>
                <el-table-column
                    prop="date"
                    label="预约时间">
                    <template slot-scope="scope"><span>{{scope.row.date | handleTime(1)}}</span></template>
                </el-table-column>
                <el-table-column
                    prop="house_id"
                    label="预约房源ID">
                </el-table-column>
                <el-table-column
                    prop="house_text"
                    label="预约房源名称">
                </el-table-column>
                <el-table-column
                    prop="to_uid"
                    label="所属员工ID">
                </el-table-column>
                <el-table-column
                    prop="staff_name_text"
                    label="所属员工">
                </el-table-column>
            </el-table>
            <lb-page
            :batch='false'
            :page='page'
            :pageSize='limit'
            :total='total'
            @handleSizeChange='handleSizeChange'
            @handleCurrentChange='handleCurrentChange'
            >
            </lb-page>
        </div>
    </div>
</template>

<script>
export default {
  data () {
    return {
      page: 1,
      limit: 10,
      total: 0,
      tableData: [],
      loading: false
    }
  },
  created () {
    let {path} = this.$route
    this.appPath = path.includes('app/') ? '/app' : ''
  },
  activated () {
    this.getTableDataList()
  },
  methods: {
    getTableDataList () {
      this.loading = true
      let {page, limit} = this
      this.$api.getHouseCustomerList({page, limit}).then(res => {
        this.loading = false
        if (res.code === 200) {
          this.tableData = res.data.data
          this.total = res.data.total
        }
      })
    },
    handleSizeChange (val) {
      this.limit = val
      this.handleCurrentChange(1)
    },
    handleCurrentChange (val) {
      this.page = val
      this.getTableDataList()
    }
  },
  filters: {
    handleTime (val, type) {
      let time = type === 1 ? moment(val * 1000).format('YYYY-MM-DD') : type === 2 ? moment(val * 1000).format('HH:mm:ss') : moment(val * 1000).format('YYYY-MM-DD HH:mm:ss')
      return time
    }
  }
}
</script>

<style lang="scss" scoped>
    .lb-app-house-customer{
        width: 100%;
        .page-main{
            width: 100%;
        }
    }
</style>
